/*
 * @Description: 
 * @Author: mmzhang
 * @Date: 2021-12-10 16:52:09
 * @LastEditTime: 2022-03-28 10:37:40
 */
import Opt from '@/components/dt/info/Opt.js'
import businessCommonMgr from '@/biz/businessReport/businessCommon'
import dateOpt from '@/biz/option/date.js'
import ruleOpt from '@/biz/option/rule.js'
import tool from '@/common/tool.js'
import clueMgr from '@/biz/businessReport/clue'
import houseOpt from '@/biz/option/house.js'
import nameOpt from '@/biz/option/name.js'
import integralMgr from '@/biz/buildingHome/integral'

let _this = null
let companys = []
class SearchOpt extends Opt {

  constructor(vm) {
    _this = vm
    super()
    this.build()
  }

  getCompany() {
    let opt = {
      title: '区域筛选',
      key: 'officeIds',
      placeholder: '全部',
      tree: {
        options: companys,
        saveParent:true
      }
    }
    let params = {
      isTwoLevel: true,
    }
    businessCommonMgr
      .getOrgThreeTree(params)
      .then((res) => {
        companys = res
        opt.tree.options = companys
      })
    return opt
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }


  createAll() {
    this.all = [
      this.getCompany(),
      houseOpt.create({
        title: '所属案场',
        placeholder: '请选择所属案场',
        to: (info) => {
          return {
            buildingName: info.housesName
          }
        }
      }),
      {
        title: '申诉角色',
        placeholder: '请选择',
        key: 'roleIds',
        select: {
          options: [],
          filterable: true,
          multiple: true,
          maxTagCount:2
        },
        load: (o) => {
          integralMgr
            .getAllRole()
            .then((res) => {
              o.select.options = res
            })
            .catch((err) => {})
        },
      }
    ]
  }
}

export default SearchOpt